import React, {Component} from 'react';
class User extends Component {
    state = {
        num: 3
    }
    componentDidMount() {
        console.log(this.props)
        this.din_shi = setInterval(()=>{
            this.setState({
                num:this.state.num-1
            })
            if(this.state.num <= 0){
                this.props.history.push('/')
            }
        },1000)
        console.log(this.din_shi )
    }
    componentWillUnmount() {
        clearInterval(this.din_shi)
    }

    render() {
        return (
            <div>
                <h5>自动返回 {this.state.num}</h5>

            </div>
        );
    }
}

export default User;